home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / MacMud / Sockets / testnetdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-12  |  793 b   |  45 lines  |  [TEXT/MPS ]

  1. #include <stdio.h>
  2. #include <memory.h>
  3. #include <devices.h>
  4. #include <files.h>
  5. #include <errors.h>
  6.  
  7. #include <sys/types.h>
  8. #include <sys/socket.h> /* for AF_INET */
  9. #include <netdb.h>
  10. #include <arpa/inet.h>
  11. #include <netinet/in.h>
  12.  
  13.  
  14. char    *h_errlist[] = {
  15.     "Error 0",
  16.     "Unknown host",                /* 1 HOST_NOT_FOUND */
  17.     "Host name lookup failure",        /* 2 TRY_AGAIN */
  18.     "Unknown server error",            /* 3 NO_RECOVERY */
  19.     "No address associated with name",    /* 4 NO_ADDRESS */
  20. };
  21. int    h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) };
  22.  
  23. extern int    h_errno;
  24.  
  25. herror(s)
  26.     char *s;
  27. {
  28.     dprintf("%s: ",s);
  29.     if (h_errno < h_nerr)
  30.         dprintf(h_errlist[h_errno]);
  31.     else
  32.         dprintf("error %d",h_errno);
  33.     dprintf("\n");
  34. }
  35.  
  36. main(argc,argv)
  37.     int argc;
  38.     char *argv[];
  39. {
  40.     char name[256];
  41.     
  42.     (void) getdomainname(name,255);
  43. }
  44.  
  45.